﻿<UserControl x:Class="V2TEK.NET.SH.Silverlight.GanttView.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    xmlns:my="clr-namespace:V2TEK.NET.SH.Silverlight.Charts;assembly=V2TEK.NET.SH.Silverlight.Charts"
    xmlns:data="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data"
    xmlns:localGrid="clr-namespace:V2TEK.NET.SH.Silverlight.Charts.TreeGridHelper;assembly=V2TEK.NET.SH.Silverlight.Charts.Core"
    xmlns:local="clr-namespace:V2TEK.NET.SH.Silverlight.GanttView"
    d:DesignHeight="300" d:DesignWidth="400">
    <UserControl.Resources>
        <DataTemplate x:Key="CallTo">
            <Grid>
                <HyperlinkButton Margin="8,8,15,0" Content="{Binding Data.TaskName}" Click="HyperlinkButton_Click" />
            </Grid>
        </DataTemplate>
        <local:RequireTimeConverter x:Key="TimeConverter"></local:RequireTimeConverter>
        <local:DateTimeConverter x:Key="DateConverter"></local:DateTimeConverter>
    </UserControl.Resources>
    <Grid x:Name="LayoutRoot" Background="White">
        <StackPanel VerticalAlignment="Top" Margin="5" Orientation="Horizontal">
            <StackPanel.Resources>
                <Style TargetType="Button">
                    <Setter Property="Margin" Value="5"></Setter>
                    <Setter Property="Width" Value="30"></Setter>
                    <Setter Property="Height" Value="30"></Setter>
                </Style>
            </StackPanel.Resources>
            <Button Content="刷新" Click="Button_Click"></Button>
            <Button 
                Width="Auto"
                Click="Button_Click_1" 
                ToolTipService.ToolTip="放大">
                <Image Source="/V2TEK.NET.SH.Silverlight.GanttView;component/images/zoom.png" />
            </Button>
            <Button   
                Width="Auto"
                Click="Button_Click_2" 
                ToolTipService.ToolTip="缩小">
                <Image Source="/V2TEK.NET.SH.Silverlight.GanttView;component/images/unzoom.png"/>
            </Button>
            <!--<Button Content="全部展开" Click="Button_Click_4"></Button>
            <Button Content="全部收起" Click="Button_Click_5"></Button>-->
            <Button  
                Width="Auto"
                Click="Button_Click_3"
                ToolTipService.ToolTip="导航到任务">
                <Image Source="/V2TEK.NET.SH.Silverlight.GanttView;component/images/gotobar.png"/>
            </Button>
            <Button Content="选择列" Width="40" Click="Button_Click_6" Visibility="Collapsed"></Button>

            <Button Visibility="Collapsed"
                    Click="Button_Click_7" 
                Width="Auto"
                ToolTipService.ToolTip="保存">
                <Image Source="/V2TEK.NET.SH.Silverlight.GanttView;component/images/save.png"></Image>
            </Button>
            <Button Content="全屏" Click="Button_Click_8"></Button>
            <Button Name="mDownloadViewField" Content="下载字段" Click="Button_Click_9" Visibility="Collapsed"></Button>
            <Button Name="mDownloadViewData" Content="下载视图" Click="mDownloadViewData_Click"  Visibility="Collapsed"></Button>
        </StackPanel>
        <my:Gantt x:Name="Gantt" LeftWidth="500" Margin="10,50,10,10">
            <my:Gantt.GanttColumns>
                <localGrid:TreeGridExpanderColumn
                                        Header=""
                                        Width="Auto"
                                        Binding="{Binding Data.WBS}">

                </localGrid:TreeGridExpanderColumn>
                <data:DataGridTemplateColumn Header="任务"
                                             Width="Auto" CellTemplate="{StaticResource CallTo}" />

                <data:DataGridTemplateColumn Header="开始日期"
                                             Width="100"
                                             IsReadOnly="True"
                                             >
                    <data:DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <Grid>
                                <TextBlock VerticalAlignment="Center" Text="{Binding Path=Data.StartDate,Converter={StaticResource DateConverter}}"></TextBlock>
                            </Grid>
                        </DataTemplate>
                    </data:DataGridTemplateColumn.CellTemplate>
                </data:DataGridTemplateColumn>


                <data:DataGridTemplateColumn Header="结束日期"
                                             Width="100"
                                             IsReadOnly="True"
                                             >
                    <data:DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <Grid>
                                <TextBlock VerticalAlignment="Center" Text="{Binding Path=Data.EndDate,Converter={StaticResource DateConverter}}"></TextBlock>
                            </Grid>
                        </DataTemplate>
                    </data:DataGridTemplateColumn.CellTemplate>
                </data:DataGridTemplateColumn>
                <data:DataGridTextColumn 
                                        Header="工期(天)" 
                                             Width="Auto"
                                        Binding="{Binding Data.TotalMilliseconds,Converter={StaticResource TimeConverter},ConverterParameter=天,StringFormat=#0}" IsReadOnly="True" />


                <data:DataGridTextColumn Header="进度"
                                             Width="Auto"
                                             IsReadOnly="False"
                                         Binding="{Binding Path=Data.PercentComplete,StringFormat=#0.#}"
                                             >

                </data:DataGridTextColumn>


                <!--<data:DataGridTemplateColumn Header="进度"
                                             Width="Auto"
                                             IsReadOnly="False"
                                             >
                    <data:DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <Grid>
                                <TextBlock VerticalAlignment="Center" Text="{Binding Path=Data.PercentComplete,StringFormat=#0.#}"></TextBlock>
                            </Grid>
                        </DataTemplate>
                    </data:DataGridTemplateColumn.CellTemplate>
                </data:DataGridTemplateColumn>-->

                <!--<data:DataGridTemplateColumn Header="资源"
                                             Width="Auto"
                                             IsReadOnly="True"
                                             >
                    <data:DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <Grid>
                                <TextBlock VerticalAlignment="Center" Text="{Binding Path=Data.Resource.DisplayName}"></TextBlock>
                            </Grid>
                        </DataTemplate>
                    </data:DataGridTemplateColumn.CellTemplate>
                </data:DataGridTemplateColumn>-->
            </my:Gantt.GanttColumns>
        </my:Gantt>
    </Grid>
</UserControl>
